Skip to content

阶段1: 底层写闸门(核心锁)(重执行) - #295

Merged
taekchef merged 1 commit into
mainfrom
codex/filemodel-phase1-write-gate
Aug 22, 2026
Merged

taekchef merged 1 commit into
mainfrom
codex/filemodel-phase1-write-gate

Conversation

@taekchef

Copy link
Copy Markdown
Collaborator

[growth-exempt: WorkspaceStore.swift 挂起/采用接线小量增长;NotesPersistence 为写闸门核心落点;阶段4 拆除冗余锁后整体净减>1000行]

背景

重执行方案阶段1。改动迁移自原 #281(整线回退前 CI 绿),基于最新 main 重新验证。方案 §5 阶段1。

实际改动

  • 新增 writeNotebookMarkdownThroughGate:全仓唯一笔记写盘闸门。文件在场时写前重读磁盘 digest:
    • 重读失败或调用方无基线 ⇒ .writeRefusedKeepContent 拒写,待写内容保留草稿
    • 摘要不符 ⇒ 待写内容先入备份环(副本先行)再抛 .diskChangedAdoptDisk,调用方采用磁盘并刷新编辑器
    • 一致 ⇒ 原子写,写后刷新双 digest
  • writeNoteMarkdownTriple 改为闸门薄封装;模板守卫此阶段并存
  • rename 标题改写直写点改走闸门(身份偷换回滚与写后校验保留)
  • repair restoreDraft / retryRestoredPendingNoteWrites / persistAgentActionNote 全部改走闸门传基线
  • WeiBeiSelfCheck 源码断言:禁止绕过闸门的新写盘点(白名单制)
  • WriteGateSafetyTests:无基线拒写/重读失败拒写/摘要不符副本先行采用磁盘/四条写路径覆盖/kill 模拟原子性

未做内容

  • swift test 由 CI 执行

共享核心面占用

  • Sources/WeiBei/Stores/WorkspaceStore.swift、Sources/WeiBeiSelfCheck/main.swift:仅本 PR 修改,合并即释放

验证

  • 本地 swift build ✅、swift run WeiBeiSelfCheck ✅
  • CI 快速编译与核心自检(全量测试,含 WriteGateSafetyTests)

回退自查表

指标 作答
可见性不回退 拒写/采用均有对应状态呈现,横幅通道不变
数据安全不回退 只增不减:旧锁全保留,闸门为新增约束
编辑不回退 待写内容永不丢弃(拒写留草稿,失配进备份环)
性能不回退 比对仅在写回时点,一次重读+digest
功能不回退 全部写路径行为等价或更安全,专项测试覆盖
可逆 单 PR revert 即恢复

@taekchef taekchef added the growth-exempt 维护者批准冻结核心文件超过 50 行的净增长 label Aug 22, 2026
@taekchef
taekchef merged commit c17f543 into main Aug 22, 2026
2 of 4 checks passed
@taekchef
taekchef deleted the codex/filemodel-phase1-write-gate branch August 22, 2026 07:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

growth-exempt 维护者批准冻结核心文件超过 50 行的净增长

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant